package com.apop.accompany.auth.controller;


import com.apop.accompany.auth.model.UserDto;
import com.apop.accompany.auth.service.lUserService;
import com.apop.common.model.PageResult;
import com.apop.common.model.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  用户前端控制器
 * </p>
 *
 * @author JiayiZheng
 * @since 2024-09-24
 */
@RestController
@RequestMapping("/v3pz/user")
public class UserController {

    @Resource
    lUserService iUserService;

    /**
     * 用户列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(name = "pageNum")  Integer pageNum,
                       @RequestParam(name = "pageSize") Integer pageSize) {
        PageResult pageList = iUserService.getUserList(pageNum,pageSize);
        return Result.success(pageList);
    }

    /**
     * 用户修改
     * @param userDto
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody UserDto userDto) {
        boolean isOk = iUserService.updateUser(userDto);
        return isOk ? Result.success("操作成功！") : Result.success("修改失败！");
    }



}
